package response;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet(name = "RequestParamsServlet", urlPatterns = "/RequestParamsServlet")
public class RequestParamsServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws SecurityException, IOException {
        response.setCharacterEncoding("utf-8");
        String name = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("用户名：" + name);
        System.out.println("密  码：" + password);
        String[] hobbys = request.getParameterValues("hobby");
        System.out.println("爱好：");
        for (int i = 0; i < hobbys.length; i++) {
            System.out.print(hobbys[i] + ", ");
        }
    }
    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response) throws SecurityException, IOException {
        doGet(request, response);
    }
}
